#include "time_utils.h"

using namespace std;

TimeUtils::TimeUtils() : timeElapsed(0) {}

void TimeUtils::Start(string msg)
{
    // cout << "------------------" << endl;
    // cout << "start " + msg << endl;
    gettimeofday(&startTime, nullptr);
}

void TimeUtils::Stop(string msg)
{
    gettimeofday(&stopTime, nullptr);
    timeElapsed = (stopTime.tv_sec - startTime.tv_sec) * 1000000.0;
    timeElapsed += (stopTime.tv_usec - startTime.tv_usec) / 1.0;
    cout<<endl;
    cout << msg + " time = " << timeElapsed << " us" << endl;
    cout << "------------------" << endl;
    cout<<endl;
}
